<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/6/3
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="/wechat/order/paying.css">
    <link rel="stylesheet" href="/wechat/order/praising.css">
    <link rel="stylesheet" href="/wechat/order/deal.css">
    <link rel="stylesheet" href="/wechat/order/praisingModify.css">
    <jsp:include page="../public/head.jsp" flush="true" />
</head>
<body>
<jsp:include page="../public/header.jsp" flush="true" />
<section>
    <div class="my_list">
        <!-- 订单状态：代付款、未评价、交易成功 GO -->
        <c:choose>
        <c:when test="${order.state == 0}">
        <div class="my_praising">

            <div class="lead_pos"><img src="/wechat/images/praisebg.png">
                <div class="txt">
                    <span class="s1">待付款 </span>
                    <span class="s2">请您在10分钟你完成订单哦。  </span>
                </div>
            </div>
            <!--/lead_pos  END -->
            <div class="addr_o">
                <div class="a_l"><a href="#"><i class="iconfont icon-me">&#xe609;</i></a></div>
                <div class="a_r">
                    <div class="txt1"><span class="s1">收货人:</span><span class="s2">${order.consignee}</span><span class="s3">${order.userMobile}</span></div>
                    <div class="clear"></div>
                    <div class="txt2"><span class="s1">收货地址：</span>${order.detail}</div>
                </div>

            </div>
            <div class="border_b"></div>
            <div class="status_list">
                <div class="tip_o"><div class="tip"> 商品信息：</div></div>
                <c:forEach items="${order.goods}" var="item">
                <div class="goodscont">

                    <div class="goods_pic"><img src="${item.productImage}"></div>
                    <div class="goods_name">
                        <div class="txt1">${item.productName}</div>
                        <div class="txt1">${item.sendDate}</div>
                        <div class="count"><span class="s1">￥${item.productPrice}</span><span class="s2">X${item.productCount}</span></div>
                    </div>
                </div>
                </c:forEach>

                <div class="info first">
                    <div class="tip">共<span class="s1">${fn:length(order.goods)}</span>件商品 总价:<span class="s1">￥${order.totalPrice}</span></div>
                </div>
                <div class="tip_o"><div class="tip"> 订单信息：</div></div>
                <div class="info">
                    <div class="txt"><span class="s1">订单号码：</span><span class="s2">${order.orderNo}</span></div>
                    <div class="txt"><span class="s1">下单时间：</span><span class="s2">${order.orderTime}</span></div>
                    <div class="txt"><span class="s1">送达时段：</span><span class="s2">${order.sendTime}</span></div>
                </div>
                <div class="info last">

                    <div class="opra">
                        <input type="button" name="" class="btn1" value="取消订单" onclick="cancelOrder('${order.id}')">
                        <%--<a href="/order/orderPay.do?orderId=${order.id}"><input type="button" name="" class="btn2" value="去付款"></a>--%>
                        <a onclick="orderPay('${order.orderNo}')"><input type="button"  class="btn2" value="去付款"></a>
                    </div>
                </div>
            </div>
        </div>
        <!--/my_list -->
        </div>
        </c:when>
        <c:when test="${order.state == 1}">
            <div class="my_praising">
                <div class="lead_pos"><img src="/wechat/images/praisebg.png">
                    <div class="txt">
                        <span class="s1">待评论 </span>
                        <span class="s2">来个评价吧，帮助我们做的更好！  </span>
                    </div>
                </div>
                <!--/lead_pos  END -->
                <div class="addr_o">
                    <div class="a_l"><a href="#"><i class="iconfont icon-me">&#xe609;</i></a></div>
                    <div class="a_r">
                        <div class="txt1"><span class="s1">收货人:</span><span class="s2">${order.consignee}</span><span class="s3">${order.userMobile}</span></div>
                        <div class="clear"></div>
                        <div class="txt2"><span class="s1">收货地址：</span>${order.detail}</div>
                    </div>
                </div>
                <div class="border_b"></div>
                <div class="status_list">
                    <div class="tip_o"><div class="tip"> 商品信息：</div></div>
                    <c:forEach items="${order.goods}" var="item">
                        <div class="goodscont">

                            <div class="goods_pic"><img src="${item.productImage}"></div>
                            <div class="goods_name">
                                <div class="txt1">${item.productName}</div>
                                <div class="txt1">${item.sendDate}</div>
                                <div class="count"><span class="s1">￥${item.productPrice}</span><span class="s2">X${item.productCount}</span></div>
                            </div>
                        </div>
                    </c:forEach>
                    <div class="info first">
                        <div class="tip">共<span class="s1">${fn:length(order.goods)}</span>件商品 总价:<span class="s1">￥${order.totalPrice}</span></div>
                    </div>
                    <div class="tip_o"><div class="tip"> 订单信息：</div></div>
                    <div class="info">
                        <div class="txt"><span class="s1">订单号码：</span><span class="s2">${order.orderNo}</span></div>
                        <div class="txt"><span class="s1">下单时间：</span><span class="s2">${order.orderTime}</span></div>
                        <div class="txt"><span class="s1">送达时段：</span><span class="s2">${order.sendTime}</span></div>
                    </div>
                    <div class="info last">
                        <div class="opra">
                            <a href="/order/orderComment.do?orderId=${order.id}"> <input type="button" name="" class="btn3" value="去评价"></a>
                        </div>
                    </div>
                </div>
            </div>
            </c:when>
            <c:when test="${order.state == 2}" >
                <div class="my_deal">
                    <div class="lead_pos"><img src="/wechat/images/praisebg.png">
                        <div class="txt">
                            <span class="s1">交易成功 </span>
                            <span class="s2">欢迎您的再次光临！  </span>
                        </div>
                    </div>
                    <!--/lead_pos  END -->
                    <div class="addr_o">
                        <div class="a_l"><a href="#"><i class="iconfont icon-me">&#xe609;</i></a></div>
                        <div class="a_r">
                            <div class="txt1"><span class="s1">收货人:</span><span class="s2">${order.consignee}</span><span class="s3">${order.userMobile}</span></div>
                            <div class="clear"></div>
                            <div class="txt2"><span class="s1">收货地址：</span>${order.detail}</div>
                        </div>
                    </div>
                    <div class="border_b"></div>
                    <div class="status_list">
                        <div class="tip_o"><div class="tip"> 商品信息：</div></div>
                        <c:forEach items="${order.goods}" var="item">
                            <div class="goodscont">
                                <div class="goods_pic"><img src="${item.productImage}"></div>
                                <div class="goods_name">
                                    <div class="txt1">${item.productName}</div>
                                    <div class="txt1">${item.sendDate}</div>
                                    <div class="count"><span class="s1">￥${item.productPrice}</span><span class="s2">X${item.productCount}</span></div>
                                </div>
                            </div>
                        </c:forEach>
                        <div class="info first">
                            <div class="tip">共<span class="s1">${fn:length(order.goods)}</span>件商品 总价:<span class="s1">￥${order.totalPrice}</span></div>
                        </div>
                        <div class="tip_o"><div class="tip"> 订单信息：</div></div>
                        <div class="info">
                            <div class="txt"><span class="s1">订单号码：</span><span class="s2">${order.orderNo}</span></div>
                            <div class="txt"><span class="s1">下单时间：</span><span class="s2">${order.orderTime}</span></div>
                            <div class="txt"><span class="s1">送达时段：</span><span class="s2">${order.sendTime}</span></div>
                        </div>

                        <!-- 评价内容 -->
                        <div class="tip_o middle"><div class="tip">评论内容：</div></div>
                        <div class="cont">
                            <div class="cont_in">
                                <div class="left" style="background: url(${order.comment.userPhoto}) 0 0 no-repeat; background-size:100% 100%;"></div>
                                <div class="center"><span class="s1">${order.comment.nickName}</span><span class="s2">${order.comment.addTime}</span></div>
                                <div class="right">${order.comment.ave}分</div>
                            </div>
                            <div class="txt">${order.comment.content}</div>
                            <div class="ocupie"></div>
                        </div>
                        <div class="info last">
                            <div class="opra">
                                <a href="tel:4006059144"> <input type="button" name="" class="btn1" value="拨打电话"></a>
                                <a href="/order/orderComplaints.do?orderId=${order.id}"><input type="button" name="" class="btn1" value="订单投诉"></a>
                                <%--<input type="button" name="" class="btn1" value="删除订单" onclick="cancelOrder('${order.id}')">--%>
                            </div>
                        </div>
                    </div>
                </div>
                <!--/my_list -->
                </div>
            </c:when>
            </c:choose>
            <!--/status_list 交易成功  END -->
            <%--<div class="statusing">正在加载...</div>--%>
        </div>
        <!--/my_list -->
    </div>
</section>
<script>
    function orderPay(orderNo) {
        <c:choose>
        <c:when test="${empty sessionScope.wxpay}">
        var http = "https://open.weixin.qq.com/connect/oauth2/authorize?";
        var appid = "&appid=wxf946190506655c2d";
        var redirect_uri = "&redirect_uri="+encodeURI("http://m.52letsgo.cn/order/orderPay.do");
        var response_type = "&response_type=code";
        var scope = "&scope=snsapi_base";
        var state = "&state="+orderNo;
        window.location.replace(http+appid+redirect_uri+response_type+scope+state+"#wechat_redirect");
        </c:when>
        <c:otherwise>
        window.location.replace("/order/orderPay.do?state="+orderNo);
        </c:otherwise>
        </c:choose>
    }

    function cancelOrder(id) {
        if (!confirm("是否删除订单")){
            return;
        }

        $.get("/mobile/user/order?action=delete&id="+id,function (data) {
            if (!data.success){
                tip("",data.msg,true);
            }else {
                window.history.go(-1);
            }
        },"json");
    }
</script>
</body>
</html>
